package com.luber.backstage.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.luber.backstage.domain.EticketInvalidSeat;
import com.luber.backstage.domain.vo.EticketInvalidSeatVO;
import com.luber.backstage.mapper.EticketInvalidSeatMapper;
import com.luber.backstage.service.IEticketInvalidSeatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 【无效座次】Service业务层处理
 *
 * @author luber
 * @date 2021-01-21
 */
@Service
public class EticketInvalidSeatServiceImpl implements IEticketInvalidSeatService
{
    @Autowired
    private EticketInvalidSeatMapper eticketInvalidSeatMapper;

    /**
     * 查询【无效座次】
     *
     * @param id 【无效座次】ID
     * @return 【无效座次】
     */
    @Override
    public EticketInvalidSeatVO selectEticketInvalidSeatById(Long id)
    {
        return eticketInvalidSeatMapper.selectEticketInvalidSeatById(id);
    }

    /**
     * 查询【无效座次】列表
     *
     * @param eticketInvalidSeat 【无效座次】
     * @return 【无效座次】
     */
    @Override
    public List<EticketInvalidSeatVO> selectEticketInvalidSeatList(EticketInvalidSeat eticketInvalidSeat)
    {
        return eticketInvalidSeatMapper.selectEticketInvalidSeatList(eticketInvalidSeat);
    }

    /**
     * 新增【无效座次】
     *
     * @param eticketInvalidSeat 【无效座次】
     * @return 结果
     */
    @Override
    public int insertEticketInvalidSeat(EticketInvalidSeat eticketInvalidSeat)
    {
        return eticketInvalidSeatMapper.insertEticketInvalidSeat(eticketInvalidSeat);
    }

    /**
     * 修改【无效座次】
     *
     * @param eticketInvalidSeat 【无效座次】
     * @return 结果
     */
    @Override
    public int updateEticketInvalidSeat(EticketInvalidSeat eticketInvalidSeat)
    {
        return eticketInvalidSeatMapper.updateEticketInvalidSeat(eticketInvalidSeat);
    }

    /**
     * 批量删除【无效座次】
     *
     * @param ids 需要删除的【无效座次】ID
     * @return 结果
     */
    @Override
    public int deleteEticketInvalidSeatByIds(Long[] ids)
    {
        return eticketInvalidSeatMapper.deleteEticketInvalidSeatByIds(ids);
    }

    /**
     * 删除【无效座次】信息
     *
     * @param id 【无效座次】ID
     * @return 结果
     */
    @Override
    public int deleteEticketInvalidSeatById(Long id)
    {
        return eticketInvalidSeatMapper.deleteEticketInvalidSeatById(id);
    }

    /**
     * 批量新增【无效座次】信息
     *
     * @param list
     * @return 结果
     */
    @Override
    public int insertListEticketInvalidSeat(List<EticketInvalidSeat> list) {
        int val = 0;
        val = eticketInvalidSeatMapper.deleteEticketInvalidSeatByModelId(list.get(0).getModelId());
        if (list.get(0).getAxisX() != null){
            for (EticketInvalidSeat eticketInvalidSeat : list) {
                val = insertEticketInvalidSeat(eticketInvalidSeat);
            }
        }
        return val;
    }
}
